import { Component, Renderer2, ViewChild } from '@angular/core';
import { ConfigModule } from 'src/app/config.module';
import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal';
import { DragDrop } from '@angular/cdk/drag-drop';

@Component({
    selector: 'app-job-log-detail-option',
    templateUrl: './index.html',
    styleUrls: ['./index.scss'],
})
export class JobLogDetailComponent {
    @ViewChild('modalContent') modalContent: any;
    modalRef: NzModalRef; //操作弹窗
    entity: any = {} as any;
    constructor(
        public _config: ConfigModule,
        private _nzModalService: NzModalService,
        private _renderer2: Renderer2,
        private _dragDrop: DragDrop,
    ) {
    }
    /**
     * 打开操作弹窗
     */
    onModalOpen(entity: string) {
        this.entity = entity;
        this.modalRef = this._nzModalService.create({
            nzTitle: "调度日志详细",
            nzContent: this.modalContent,
            nzFooter: null,
            nzWidth: this._config.modalWidth,
            nzBodyStyle: this._config.modalContentHeight,
        });

        this.modalRef.afterOpen.subscribe(() => {
            const modalDragRef = this._renderer2.selectRootElement('.ant-modal-content', true);
            const modalDragHeaderRef = this._renderer2.selectRootElement('.ant-modal-header', true);
            const modalDrag = this._dragDrop.createDrag(modalDragRef);
            modalDrag.withHandles([modalDragHeaderRef]);
            modalDrag.withBoundaryElement(document.body);
        });
    }
}
